<!--XOA MAU-->
<?php
if (isset($_GET['remove']))
{
    $mauid = $_GET ['mauid'];
    $result = mysql_query("DELETE FROM mau where mauid = $mauid; ");
    if ($result)
        print "<script> alert ('Thành công !')</script>";
}
?>

<!--FORM THEM MAU-->
<form action="index.php?quanlybanhang&module=mau" method="post" enctype="multipart/form-data">
<fieldset>
<legend><h1>Thêm mới màu</h1></legend>
<table width="408" border="0">
  <tr>
    <td width="74">Tên màu</td>
    <td width="318"><label>
      <input type="text" name="tenmau" id="textfield" />
    </label></td>
  </tr>
  <tr>
    <td>Mã màu</td>
    <td><label> <!--  Thêm màu <input type="text" name="mamau"/> <input class="color" type="text" value="66ff00" name="mamau"/> -->
        <input class="color {hash:true}" name="mamau" />
        </label></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input class="button" type="submit" name="submit" value="Thêm" /></td>
  </tr>
</table>
</fieldset>
</form>

<!--PHP THEM MAU-->
<?php
if (isset($_POST['submit']))
{
    //print_r ($_POST);
    $tenmau      =   $_POST['tenmau'];
    $mamau    =   $_POST['mamau'];
    $mysql = "insert into mau (tenmau, mamau) values ('$tenmau', '$mamau')";
    $result = mysql_query($mysql);
    if ($result)
        print '<h2>Thành công !</h2>';
}
?>

<!--HIEN THI CAC MAU-->
<fieldset>
<legend><h1>Danh sách màu:</h1></legend>
<table width="695" border="0">
    <tr>
        <td width="100"><b>ID</b></td>
        <td width="200"><b>Tên màu</b></td>
        <td width="200"><b>Mã màu</b></td>
        <td width="200"><b>Xóa</b></td>
    </tr>

    <?php
        $mau = mysql_query("select * from `mau`");
        while ($row = mysql_fetch_array($mau))
        {
    ?>
    <tr>
        <td width="100"><?php print "$row[mauid]"; ?> </td>
        <td width="200"><?php print "$row[tenmau]"; ?> </td>
        <td width="200"><?php print "<div style='width: 100px; height: 20px; background:$row[mamau] ;'></div>"; ?> </td>
        <td width="200">
        <a href="index.php?quanlybanhang&module=mau&mauid=<?php print "$row[mauid]"; ?>&remove" onclick="return confirm('Muốn xóa thật ko?')" >Xóa</a>
        </td>
    </tr>
    <?php 
        }
    ?>
</table>
</fieldset>
<div style="width: 30px; height: 20px; background: ;"></div>
